package com.ay272.sshupdate.dao;

import com.ay272.sshupdate.entity.QianDao;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * Created by java on 2016/5/25.
 */
@Repository
public class QianDaoDaoImpl extends HibernateDaoSupport implements QianDaoDao {
    @Autowired
    private SessionFactory mySessionFactory;
    @PostConstruct
    public  void  set(){
        this.setSessionFactory(mySessionFactory);
    }
    @Override
    public void save(QianDao qianDao) {
       this.getHibernateTemplate().save(qianDao);
    }
    @Override
    public List<QianDao> list() {
        return (List<QianDao>) this.getHibernateTemplate().find("from QianDao");
    }
}
